package cn.wolfcode.luowowo.article.service.impl;

import cn.wolfcode.luowowo.article.domain.Attraction;
import cn.wolfcode.luowowo.article.domain.Destination;
import cn.wolfcode.luowowo.article.mapper.AttractionMapper;
import cn.wolfcode.luowowo.article.mapper.DestinationMapper;
import cn.wolfcode.luowowo.article.query.AttractionQuery;
import cn.wolfcode.luowowo.article.service.IAttractionService;
import com.alibaba.dubbo.config.annotation.Service;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

@Service
public class AttractionServiceImpl implements IAttractionService {
    @Autowired
    private AttractionMapper attractionMapper;
    @Autowired
    private DestinationMapper destinationMapper;
    @Override
    public List<Attraction> top5ListByDestId(Long destId) {
        List<Attraction> list = attractionMapper.selectTop5(destId);
        return list;
    }

    @Override
    public Destination getDestInfoByDestId(Long destId) {
        return destinationMapper.selectByPrimaryKey(destId);
    }

    @Override
    public List<Attraction> getHot10() {
        return attractionMapper.selectHot10();
    }

    @Override
    public PageInfo<Attraction> list(AttractionQuery qo) {
        PageHelper.startPage(qo.getCurrentPage(),qo.getPageSize());
        return new PageInfo<Attraction>(attractionMapper.selectAll());
    }

    @Override
    public Attraction getbyId(Long attrId) {
        return attractionMapper.selectByPrimaryKey(attrId);
    }

    @Override
    public List<Attraction> inAttrbyId(Long attrId) {
        return attractionMapper.selectInAttrbyId(attrId);
    }

    @Override
    public List<Attraction> getAll() {
        return attractionMapper.selectAll();
    }

}
